<?php

global $prefix;

$gallery = get_post_meta($post->ID, $prefix.'_gallery', true);
$postid = $post->ID;

?>	
	
<?php  
	if ( !is_singular() ) {
	?>
	<?php
$medias = substr($gallery, 3);
$medias = explode('~~~', $medias);

$output_medias = '';
foreach ($medias as $media) {
	$object = explode('~~', $media);
	$type = $object[0];
	$id = $object[1];
	$val = $object[2];
	
	$output_medias .= "<li>"; 
	if ($type == 'image') { 
		$image = wp_get_attachment_image_src($val, 'full'); $image = $image[0];
		$thisimage = '<img src="'.$image.'" alt=""/>';
		if(get_option($prefix.'_disablefancybox') !== "on") {
			$output_medias .= '<a href="'.$image.'" class="openfancybox" rel="gallery'.get_the_ID().'">'.$thisimage.'</a>';
		} else {
			$output_medias .= $thisimage;
		}
	} else {
		$output_medias .= '<div class="video-container">'.$val.'</div>';
	}
	$output_medias .= "</li>";
}

?>
    
     <div class="posttype"><div id="banner">
     <section class="flexslider">
     
               <ul class="unstyled slides">
                    <?php echo $output_medias; ?>
                </ul>
           
      </section>
</div> </div>

  <div class="text">
                    <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
                    <p class="meta"><?php the_time('F j, Y') ?></p>   

                       <p><?php cl_excerpt('cl_excerptlength_post', 'cl_excerptmore'); ?></p>
                    </div>
                                   <div class="categoriess"><?php the_category(' '); ?></div>
	<div class="postauthors"><?php the_author_posts_link(); ?></div>
    <div class="postcomments"><?php comments_popup_link(__('No Comments', 'themeText'), __('1 Comment', 'themeText'), __( '% Comments', 'themeText') ); ?></div>   

    
<?php } else { ?>
	<?php
$medias = substr($gallery, 3);
$medias = explode('~~~', $medias);

$output_medias = '';
foreach ($medias as $media) {
	$object = explode('~~', $media);
	$type = $object[0];
	$id = $object[1];
	$val = $object[2];
	
	$output_medias .= "<li>"; 
	if ($type == 'image') { 
		$image = wp_get_attachment_image_src($val, 'full'); $image = $image[0];
		$thisimage = '<img src="'.$image.'" alt=""/>';
		if(get_option($prefix.'_disablefancybox') !== "on") {
			$output_medias .= '<a href="'.$image.'" class="openfancybox" rel="gallery'.get_the_ID().'">'.$thisimage.'</a>';
		} else {
			$output_medias .= $thisimage;
		}
	} else {
		$output_medias .= '<div class="video-container">'.$val.'</div>';
	}
	$output_medias .= "</li>";
}

?>
    
     <div class="posttype"><div id="banner">
     <section class="flexslider">
     
               <ul class="unstyled slides">
                    <?php echo $output_medias; ?>
                </ul>
           
      </section>
</div> </div>

  <div class="text">
                    <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
                    <p class="meta"><?php the_time('F j, Y') ?></p>   

                       <p><?php the_content(); ?></p>
                    </div>
                                   <div class="categoriess"><?php the_category(' '); ?></div>
	<div class="postauthors"><?php the_author_posts_link(); ?></div>
    <div class="postcomments"><?php comments_popup_link(__('No Comments', 'themeText'), __('1 Comment', 'themeText'), __( '% Comments', 'themeText') ); ?></div>   
<?php } ?>